package com.ushine.web.template.decryption.controller;

import com.ushine.web.component.http.HttpResponseVO;
import com.ushine.web.template.decryption.model.FieldDecryptionDO;
import com.ushine.web.template.decryption.service.IFieldDecryptionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author: yls
 * @Date 2022/2/11 15:40
 * @Description: 字段加密
 * @Version 1.0
 **/
@RestController
@Api(tags = "组件模块-字段加密测试")
@RequestMapping("component/decry")
public class FieldDecryptionController {
    @Resource
    private IFieldDecryptionService fieldDecryptionService;

    @ApiOperation(value = "添加数据")
    @PostMapping("insert")
    public HttpResponseVO<Object> insert(@RequestBody FieldDecryptionDO fieldDecryption) {
        Boolean flag = fieldDecryptionService.insert(fieldDecryption);
        if (Boolean.TRUE.equals(flag)) {
            return new HttpResponseVO<>().ok("添加成功");
        }
        return new HttpResponseVO<>().ok("添加失败");
    }

    @ApiOperation(value = "查询数据")
    @GetMapping("list")
    public HttpResponseVO<List<FieldDecryptionDO>> listFieldDecryptions() {
        List<FieldDecryptionDO> fieldDecryptions = fieldDecryptionService.listFieldDecryptions();
        return new HttpResponseVO<List<FieldDecryptionDO>>().ok("", fieldDecryptions);
    }
}
